import {drizzle} from 'drizzle-orm/mysql2'
import {createPool} from 'mysql2'
import * as schema from '../schema/schema'
import * as relations from '../schema/relations'

const poolConn = createPool({
  user: 'root',
  password: '123456',
  host: '127.0.0.1',
  port: 3306,
  database: 'elysia-rms',
})
const db = drizzle(poolConn, {schema: {...schema, ...relations}, mode: 'default'})

export default db

export type DB = typeof db
